package com.amgl.mobike.app.glide;

import android.app.Activity;
import android.net.Uri;
import android.widget.ImageView;

import com.amgl.mobike.R;
import com.amgl.mobike.app.IImageLoader;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

/**
 * Created by 阿木 on 2017/3/10.
 */

public class ActivityImageLoader implements IImageLoader {
    Activity mActivity;

    public ActivityImageLoader(Activity activity) {
        mActivity = activity;
    }

    @Override
    public void loadImage(ImageView imageView, Uri imageUri) {
        Glide.with(mActivity).load(imageUri).placeholder(R.color.image_default).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
    }

    @Override
    public void loadImage(ImageView imageView, Uri imageUri, int width, int height) {
        Glide.with(mActivity).load(imageUri).placeholder(R.color.image_default).override(width, height).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
    }

    @Override
    public void loadGif(ImageView imageView, Uri imageUri) {
        Glide.with(mActivity).load(imageUri).asGif().placeholder(R.color.image_default).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
    }

    @Override
    public void loadGif(ImageView imageView, Uri imageUri, int width, int height) {
        Glide.with(mActivity).load(imageUri).asGif().placeholder(R.color.image_default).override(width, height).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
    }
}
